package com.mike.bdb.util;

public class ClassNameUtil {
	
	/***
	 * 获得类名的简单类名
	 * @param className	类名字符串
	 * @return			简单类名字符串
	 */
	public static String getSimpleName(String className) {
		String result = null;
		if(null == className || "".equals(className.trim())) return result;
		boolean contains = className.contains(".");
		if(contains) {
			String[] split = className.split("\\.");
			result = split[split.length - 1];
		} else {
			result = className;
		}
		return result;
	}
	
	public static String getSimpleNameWithSuffix(String className) {
		String simpleName = getSimpleName(className);
		if(null == simpleName) {
			return null;
		}
		return simpleName + ".java";
	}
	
	public static void main(String[] args) {
		System.out.println(getSimpleName("sdfasdf.sdfsdf.sdfasdf.Msda"));
		System.out.println(getSimpleName("Msda"));
		System.out.println(getSimpleName(""));
		System.out.println(getSimpleName(null));
		System.out.println(getSimpleNameWithSuffix("sdfasdf.sdfsdf.sdfasdf.Msda"));
		System.out.println(getSimpleNameWithSuffix("Msda"));
		System.out.println(getSimpleNameWithSuffix(""));
		System.out.println(getSimpleNameWithSuffix(null));
	}
	
}
